home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Games of Daze
/
Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso
/
x2ftp
/
msdos
/
vla
/
dir_vla
/
d.nfo
< prev
next >
Wrap
Text File
|
1993-09-15
|
5KB
|
158 lines
09-16-1993
This is yet another small VLA tutorial. This one deals (kinda) with
some of the odd, yet useful, DOS disk functions.
I'll just start by making note of some facts that I found useful:
■ When you enter a program, be it an EXE or a COM, ES = the PSP segment.
The ENVIRONMENT segment is found a offset 2ch in the PSP segment.
So to grab it you'd do:
mov ax,[es:2ch] ;ax now conains the ENVIRONMENT seg
I didn't actually need to use this in this program, but it IS useful
for scanning for sound card settings and for finding where the
command interperator is (COMSPEC=C:\COMMAND.COM)
All the entries are ASCIIZ strings.
■ The DTA, again whether you are in a COM or an EXE, begins at offset 80h
in the PSP. This is where your command line is initially, and is
also used as a work area by DOS for file searches.
■ You can relocate the DTA by using FN# 1Ah, INT 21h and setting
DS:DX to the new location.
■ FN# 2Fh, INT 21h returns the DTA address in ES:BX
Now the cool functions:
■ FN# 19h, Report current drive.
IN: AH = 19h
OUT: AL = drive ID (0=A, 1=B, 2=C, etc.)
■ FN# 0Eh, Set current drive.
IN: AH = 0Eh
DL = drive ID (0=A, 1=B, 2=C, etc.)
OUT: AL = number of drives installed
■ To find out how many drives are installed, do this:
mov ah,19h
int 21h
mov dl,al
mov ah,0eh
int 21h
;al = # of installed drives
■ FN# 36h, Get disk free space.
IN: AH = 36h
DL = drive ID + 1, (0=current drive, 1=A, 2=B, 3=C, etc.)
OUT: AX = Sectors per Cluster
BX = Available cluster count
CX = Bytes per sector
DX = Total clusters
■ Total free space = AX * BX * CX
■ Total space (disk size) = AX * CX * DX
■ Percentage of disk available = (BX * 100) / DX
■ I used the above formula to get the percentage, but then used
a small bit of cleverness to extend the precision out to 3 places.
P = BX * 100 / DX
Precision = (BX * 100 * 1000 / DX) - (P * 1000)
Then print out P and then a decimal point and then print the
precision.
■ FN# 4Eh, Find first matching file.
IN: AH = 4Eh
CX = attributes to match
DS:DX = pointer to filespec ASCIIZ string
OUT: AX = return code, 2 = file not found,
18 = no more files to be found
■ This function fills in the DTA area with a 43 byte structure:
STRUC DTA
stuff db 21 dup (?) ;dos work area for finding next file
Attr db ? ;attribute of file
Time dw ? ;time stamp
Date dw ? ;date stamp
Size dd ? ;size of the file
Fname db 13 dup (0) ;ASCIIZ filename (no dot if no EXT)
ENDS
■ Attribute:
bit 1 = Read Only
2 = Hidden
3 = System
4 = Volume label
5 = Subdirectory
6 = Archive
7-8 = Unused
The only flag of any importance is the volume label. If you set
this flag, the search will ONLY search for directories. If it is
not set, it will match all normal files plus any that have the
attributes set in any combination. For example:
A attribute flag of 00110111b in cx will find ALL files and
subdirectories. A flag of 00011000b will find ONLY directories.
00000001b will find all normal files and any file with READ ONLY
set, but no other attributes.
■ Time stamp:
Time = Hour * 2048 + Minutes * 32 + seconds / 2
Hour = Time >> 11
Minute = (Time >> 5) & 63
Seconds = (Time << 1) & 63
■ Date stamp:
Date = (Year - 1980) * 512 + Month * 32 + Day
Year = 1980 + (Date >> 9)
Month = (Date >> 5) & 16
Day = Date & 32
■ Filename:
An ASCIIZ string, just like any other filename. If there is no
extension, there is no "."
■ FN# 4Fh, Find next matching file.
IN: AH = 4Fh
CX = attributes to match
DS:DX = pointer to filespec ASCIIZ string
OUT: AX = return code, 18 = no more files to be found
■ This just continues the file search started by FN# 4Eh
Well, that's just about it... Oh, well, that's an end to this doc.
Draeden /VLA